//index.js
const app = getApp()

Page({
  data: {
    imgUrls: [
      'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
      'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
      'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
    ],
     indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    popup:true
    
  },
   hidePopup(flag = true) {
    this.setData({
      "popup": flag
    });
  },
  /* 显示弹窗 */
  showPopup() {
    this.hidePopup(false);
  },
  fast(){
    wx.navigateTo({
      url: '../fast/fast',
    })
  },
  goCou(){
    wx.navigateTo({
      url: '../coupon/coupon',
    })
  },


  onLoad: function() {
    
    // wx.request({
    //   // url: 'https://www.daxunxun.com/banner',
    //   url:'https://v.juhe.cn/toutiao/index?type=top&key=APPKEY',
    //   success: res =>{
    //     console.log(res.data)
    //     this.setData({
    //       imgUrls: res.data
    //     })
    //   }
    // })
		
    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
          wx.getUserInfo({
            success: res => {
              this.setData({
                avatarUrl: res.userInfo.avatarUrl,
                userInfo: res.userInfo
              })
            }
          })
        }
      }
    })
  },

  onGetUserInfo: function(e) {
    if (!this.logged && e.detail.userInfo) {
      this.setData({
        logged: true,
        avatarUrl: e.detail.userInfo.avatarUrl,
        userInfo: e.detail.userInfo
      })
    }
  }
})